package com.wlts.wzy.KSGoodsModule.controller;


import com.wlts.wzy.Base.BaseEntity;
import com.wlts.wzy.KSGoodsModule.entity.KsCategory;
import com.wlts.wzy.KSGoodsModule.service.IKsCategoryService;
import com.wlts.wzy.Result.Result;
import com.wlts.wzy.api.request.ks.KsCategoryPageRequest;
import com.wlts.wzy.expand.MyLambdaQueryWrapper;
import com.wlts.wzy.expand.MyPage;
import com.wlts.wzy.util.CopyUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 快手商品类目表 前端控制器
 * </p>
 *
 * @author zhiyong
 * @since 2021-01-31
 */
@Api(tags = "快手商品类目表 前端控制器")
@RestController
@RequestMapping("/KSGoodsModule/ks-category")
public class KsCategoryController {
    @Autowired
    private IKsCategoryService ksCategoryService;

    @ApiModelProperty("分页获得快手商品分类")
    @RequestMapping(value = "getKsCategoryPage", method = RequestMethod.POST)
    public Result<MyPage<KsCategory>> getKsCategoryPage(@RequestBody KsCategoryPageRequest request) {

        //System.out.println(request.toString());

        MyLambdaQueryWrapper<KsCategory> queryWrapper = new MyLambdaQueryWrapper<>();

        queryWrapper.eq(BaseEntity::getDelFlag, "0");

        queryWrapper.eq(KsCategory::getCategoryPid,request.getCategoryPid());

        MyPage<KsCategory> page = ksCategoryService.page(queryWrapper, request.getCurrentPage(), request.getPageSize(), true);

        return Result.buildResult(page);
    }


}